<?php
ini_set("display_errors", "1");
require 'SQL_to_PHP.class.php';

if(isset($_GET['convert'])){
	
	if($_POST['textfield'] == "" || $_POST['textfield2'] == "" || $_POST['textfield4'] == ""){
		$error = "Blank textfield!";
	}else{
		$Classe_mysql_to_php = new MySQL_to_PHP($_POST['textfield'], $_POST['textfield2'], $_POST['textfield3'], $_POST['textfield4']);
	
		if(isset($_POST['fetch_all'])) $Classe_mysql_to_php->setfetchData(true); else $Classe_mysql_to_php->setfetchData(false);
		if(isset($_POST['delete'])) $Classe_mysql_to_php->setdelete(true); else $Classe_mysql_to_php->setdelete(false);
		if(isset($_POST['update'])) $Classe_mysql_to_php->setupdate(true); else $Classe_mysql_to_php->setupdate(false);
		if(isset($_POST['insert'])) $Classe_mysql_to_php->setinsert(true); else $Classe_mysql_to_php->setinsert(false);
		if(isset($_POST['Order_Keys'])) $Classe_mysql_to_php->setOrder_Keys(true); else $Classe_mysql_to_php->setOrder_Keys(false);
		if(isset($_POST['geters'])) $Classe_mysql_to_php->setGeters(true); else $Classe_mysql_to_php->setGeters(false);
		if(isset($_POST['seters'])) $Classe_mysql_to_php->setseters(true); else $Classe_mysql_to_php->setseters(false);	
		
		$Classe_mysql_to_php->CreateClassesFiles();
		$error = "Classes Created!";
	}

}
?>
<style type="text/css">
<!--
.title {
	font-size: 14px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #0000FF;
	font-weight: bold;
}
.text {
	font-family: Verdana, Arial, Helvetica, sans-serif; 
	font-size: 10px; 
}
.style7 {font-weight: bold}
.style8 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-weight: bold; }
.style9 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-style: italic; }
.style10 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
<form id="form1" name="form1" method="post" action="?convert">
  <table width="741" border="0" align="center">
    <tr>
      <td height="30" colspan="3" bgcolor="#EEEEEE" class="title">Convert: MySQL Table -&gt; php class</td>
    </tr>
    <tr>
      <td height="30" colspan="2" class="text"><div align="left"><strong>Connect settings </strong></div></td>
      <td width="358" class="style10"><?php if(isset($error)){ echo $error; }?></td>
    </tr>
    <tr>
      <td width="225" class="text"><div align="right"><span class="style7">Server Host </span></div></td>
      <td width="144"><label>
        <input name="textfield" type="text" value="localhost" />
      </label></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="text"><div align="right"><span class="style7">Username</span></div></td>
      <td><label>
        <input name="textfield2" type="text" value="root" />
      </label></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="text"><div align="right"><span class="style7">Password</span></div></td>
      <td><label>
        <input type="password" name="textfield3" />
      </label></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="text"><div align="right"><span class="style7">DataBase Name </span></div></td>
      <td><label>
        <input type="text" name="textfield4" />
      </label></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td height="30" colspan="2" class="style8">Function settings generating </td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td class="style8"><div align="right">Fetch functions </div></td>
      <td colspan="2"><em>
        <label>
        <input name="fetch_all" type="checkbox" value="true" checked="checked" />
        <span class="text"> Fetch All And Include Other functions</span></label>
      </em></td>
    </tr>
    <tr>
      <td class="style8"><div align="right">Delete </div></td>
      <td colspan="2"><em>
        <input name="delete" type="checkbox" value="true" checked="checked" />
        <span class="text">public function Delete</span></em></td>
    </tr>
    <tr>
      <td class="style8"><div align="right">Upadte </div></td>
      <td colspan="2"><em>
        <label>
        <input name="update" type="checkbox" value="true" checked="checked" />
        <span class="text">public function Update</span></label>
      </em></td>
    </tr>
    <tr>
      <td class="style8"><div align="right">Insert</div></td>
      <td colspan="2"><em>
        <label>
        <input name="insert" type="checkbox" value="true" checked="checked" />
        <span class="text">public function Insert</span></label>
      </em></td>
    </tr>
    <tr>
      <td class="style8"><div align="right">Get Records By </div></td>
      <td colspan="2" class="text"><em>
        <label>
        <input name="Order_Keys" type="checkbox" value="true" checked="checked" />
      public function GetKeysOrderBy</label>
      </em></td>
    </tr>
    <tr>
      <td class="style8"><div align="right">Getters Methods</div></td>
      <td colspan="2" class="text"><em>
        <label>
        <input name="geters" type="checkbox" value="true" checked="checked" />
      public function get</label>
      </em></td>
    </tr>
    <tr>
      <td class="style8"><div align="right">Setters Methods</div></td>
      <td colspan="2" class="style9"><label>
        <input name="seters" type="checkbox" value="true" checked="checked" />
      </label>        <label>public function Set</label></td>
    </tr>
    <tr>
      <td class="style8">&nbsp;</td>
      <td><p>&nbsp;</p>
      <p>&nbsp;</p></td>
      <td><input type="submit" name="Submit" value="Generate now" /></td>
    </tr>
  </table>
</form>
